﻿/*
 * Created by SharpDevelop.
 * User: StrunevskyDV
 * Date: 02.03.2010
 * Time: 10:06
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using EmailJabber.Entities.Entities;
using FinancialPersonal.Base;

namespace FinancialPersonal.Entities
{
	/// <summary>
	/// Description of UserEntity.
	/// </summary>
	public class UserEntity:EntityBase
	{
		public UserEntity()
		{
			Id = Guid.NewGuid();
		}
		
		[Category("Общее")]
		[DisplayName("Имя")]
		public string Name{get;set;}
		public string Jid{get;set;}
		
		[Browsable(false)]
		public Decimal MonthlyIncome{get;set;}
		
		public decimal CurrencyRate{get;set;}
		
		[Category("Общее")]
		[DisplayName("Дата начислений")]
		public int DateMonthlyIncome {get;set;}
		
		[Category("Общее")]
		[DisplayName("Тратится денег в месяц")]
		[Description("Каждый месяц необходимо расходовать столько денег")] 
		[TypeConverter(typeof(DecimalTypeConverter))]
		public Decimal SpendMoneyPerMonth {
			get{
				decimal total = 0;
				foreach(GoalEntity goal in Goals)
				{
					total+=goal.MoneyPerMonth;
				}
				foreach(RepeatedOutcomeEntity payment in RepetatedPayment)
				{
					total+=payment.MoneyPerMonth;
				}
				return total;
			}
		}
		
		[Category("Долгосрочные")]
		[Description("Денег откладывать каждый месяц в долгосрочные сбережения")] 
		[TypeConverter(typeof(DecimalTypeConverter))]
		public Decimal MoneyOnBillMonthly
		{
			get
			{
				decimal total = 0;
				foreach(GoalEntity goal in Goals)
				{
					total+=goal.MoneyPerMonth;
				}
				foreach(RepeatedOutcomeEntity payment in RepetatedPayment)
				{
					if(payment.RepeatPeriod > 1)
					{
						total+=payment.MoneyPerMonth;
					}
				}
				return total;
			}
		}
		
		
		[Category("Долгосрочные")]
		[Description("Денег должно быть в долгосрочных сбережениях")] 
		[DisplayName("Денег на счету")]
		[TypeConverter(typeof(DecimalTypeConverter))]
		public Decimal MoneyNowInBill
		{
			get
			{
				decimal total = 0;
				foreach(GoalEntity goal in Goals)
				{
					total+=goal.MoneyNow;
				}
				foreach(RepeatedOutcomeEntity payment in RepetatedPayment)
				{
					if(payment.RepeatPeriod > 1)
					{
						total+=payment.MoneyNow;
					}
				}
				return total;
			}
		}
		
		[Browsable(false)]
		public DateTime LastWeekendMessageSend {get;set;}
		[Browsable(false)]
		public DateTime LastMonthlyMessageSend {get;set;}
		
		[Category("Расходы")]
		[DisplayName("Цели")]
		public List<GoalEntity> Goals{get;set;}
		
		[Category("Расходы")]
		[DisplayName("Повторные платежие")]
		public List<RepeatedOutcomeEntity> RepetatedPayment{get;set;}
	}
}
